package com.xyh.flowershop.utils;



import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Random;
import java.util.UUID;

/**
 * @author 小约翰可汗
 * @className CommonUtils
 * @createTime 2024/4/1720:32
 */
public class CommonUtils {

    public static String randomUser(){
        Random random = new Random();
        int index = random.nextInt(24);
        return "用户"+ UUID.randomUUID().toString().substring(0,index);
    }

    public static String formatDate(LocalDateTime date){
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return date.format(formatter);
    }

    public static String formatDate(Date date){
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return  formatter.format(date);
    }

    public static  String generateCode(){
        Random random = new Random();
        int code = random.nextInt(100000);
        return String.format("%06d", code);
    }
}
